package com.chinairi.mall.config;

import com.chinairi.mall.service.IContractMaitainService;
import com.chinairi.mall.service.ISysUserLoginService;
import com.chinairi.mall.service.IUserCompanyInfoService;
import com.chinairi.mall.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author webgasd
 */
@Component
public class SyncTask {
    @Autowired
    private IContractMaitainService iContractMaitainService;
    @Autowired
    private ISysUserLoginService iSysUserLoginService;
    @Autowired
    private IUserCompanyInfoService iUserCompanyInfoService;
    @Autowired
    private UserCompanyInfoServiceImpl userCompanyInfoService;
    @Autowired
    private MaterialServiceImpl materialService;
    @Autowired
    private ProjectServiceImpl projectService;
    @Autowired
    private SysUserServiceImpl sysUserService;
    @Autowired
    private SysUserLoginServiceImpl sysUserLoginService;


    /**
     * 每隔2小时，将定时任务添加为可执行，cron标签指向了任务开始时间。可以利用定时中台。
     */
    @Scheduled(cron = "0 0 0/2 * * ?")
    public void cronJob1() {
        iContractMaitainService.updateCheck();
    }

    /**
     * 每隔1小时的定时任务放在这里
     */
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void cronJob4() {
        userCompanyInfoService.putRedis();
        userCompanyInfoService.putShopInfoToRedis();
    }

    /**
     * 每隔1天的定时任务放在这里
     */
    @Scheduled(cron = "0 0 0 1/1 * ?")
    public void cronJob5() {
        iSysUserLoginService.updateCheck();
        iUserCompanyInfoService.updateStatus();
        userCompanyInfoService.putAdminInfoToRedis();
        materialService.putRedis();
        projectService.putRedis();
        sysUserService.putRedis();
        sysUserLoginService.setAreaMapToRedis();
    }
}
